var data0;

function splitData(rawData) {
  const categoryData = [];
  const values = [];
  for (var i = 0; i < rawData.length; i++) {
    categoryData.push(rawData[i].splice(0, 1)[0]);
    values.push(rawData[i]);
  }
  return {
    categoryData: categoryData,
    values: values,
  };
}

function getDate(name, date) {
  const upColor = '#ec0000';
  const upBorderColor = '#8A0000';
  const downColor = '#00da3c';
  const downBorderColor = '#008F28';

  // Each item: open，close，lowest，highest

  var htmlobj = $.ajax({
    url: 'https://api.doctorxiong.club/v1/stock/kline/day?code=' +
      name +
      '&startDate=' +
      date[0] +
      '&endDate=' +
      date[1],
    async: false,
  });
  data0 = splitData(JSON.parse(htmlobj.responseText).data);
}

getDate('sh000001', ['2022-01-29', '2022-03-08']);